package com.jjwt.demo;

import org.junit.Test;

import java.util.*;

public class Test01 {
    @Test
    public void test22(){
        List<String> list=new ArrayList<>();
        list.add("a");
        list.add("abc");
        list.add("ab");
        list.add("ac");
        list.add("a");
        list.add("b");
        list.add("b");
        list.add("b");
        List<String> list1=new ArrayList<>();
        Set<String> set=new HashSet<>();
        for (String s : list) {
            if(list1.contains(s)){
                list1.add(s);
            }else{
                set.add(s);
            }
        }
        for (String s : set) {
            System.out.println(s);
        }
    }
    @Test
    public void test33(){
        List<String> list=new ArrayList<>();
        list.add("a");
        list.add("abc");
        list.add("ab");
        list.add("ac");
        list.add("a");
        list.add("b");
        list.add("b");
        list.add("b");
        removeDuplicateWithOrder(list);

    }
    public static void removeDuplicateWithOrder(List list){
        Set set=new HashSet();
        List newlist=new ArrayList();

        Iterator iterator=list.iterator();
            while(iterator.hasNext()){
            Object next = iterator.next();
            if(set.add(next)){
                newlist.add(next);
            }
        }
        list.clear();
        list.addAll(newlist);
        System.out.println(list);
    }
    @Test
    public void test44(){
        String [] iofoss={"1,张三,29","2,李四,12","3,张三,21","4,三大,21"};
        Map<String,Integer> map=new HashMap<>();
        for (String s : iofoss) {
            String[] split = s.split(",");
            String s1 = split[1];
            if(!map.containsKey(s1)){
                map.put(s1,1);
            }else{
                Integer integer = map.get(s1);
                map.put(s1,integer+1);
            }
        }
        Integer max = Collections.max(map.values());
        Set<String> set = map.keySet();
        StringBuffer stringBuffer=new StringBuffer();
        for (String s : set) {
            Integer integer = map.get(s);
            if(integer==max){
                stringBuffer.append(s);
            }
        }
        System.out.println(stringBuffer+"       "+max);
    }
    @Test
    public void test03(){

        String v="a"+"c";
        String e=new String (v);
        System.out.println(e=="ac");
        Map<String,String> map=new HashMap<>();
        map.put("1","11");
        map.put("2","22");
        map.put("3","33");
        Set<String> set = map.keySet();
        for (String s : set) {
            System.out.println(s);
            String s1 = map.get(s);
            System.out.println("s1 = " + s1);
        }
        for (Map.Entry<String,String> entry:map.entrySet()){
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println("key = " + key);
            System.out.println("value = " + value);
        }
    }

}
